home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / 422mods.zip / TPRO01.422 < prev    next >
Text File  |  1993-03-03  |  16KB  |  518 lines

  1. TPRO01.MOD - Use macro for name display
  2. 2THE 1Programmer0 #1 @5920
  3. Fri Feb 26 02:43:44 1993
  4. ┌────────────────────────────────────────────────────────────────────────────┐
  5. │   Mod Name: TPRO01.MOD                    Author: 2THE 1Programmer           │0
  6. │ Difficulty: Not the easiest                 Date: Feb 9, 1993              │
  7. │    Version: 4.22 (Will work with others)                                   │
  8. │Description: Allows users to have a macro show their name.  Lets sysops     │
  9. │             display just the users name.                                   │
  10. └────────────────────────────────────────────────────────────────────────────┘
  11. This will take some time to install.  6Read the ENTIRE MOD FIRST0 to make
  12. sure that you can install it correctly.
  13.  
  14. This mod has been tested as bug free.  It has beed beta tested with several
  15. othere WWIV sysops and has been found as such.  Please support bug free mods.
  16.  
  17. Now for the disclaimer.  It works just fine on my system.  Don't blame me if
  18. you didn't back up your source.
  19.  
  20. Now for a better description.  What this does is allow you to use a macro
  21. to show your name.  You can put WWIV color commands in it and IBM characters
  22. too.  This way you can have like special casing of your name (look at mine).
  23.  
  24. As a benefit.  I added a function that would print out just the username
  25. without any numbers after it.  Just call it like:
  26.  
  27.   s=name(thisuser);
  28.  
  29. And you will have the name by itself.
  30.  
  31. Included is a restriction so that you can set it up so that someone can not
  32. use it.  I have it set to 'O'.  You can change it to whatever you want to.
  33.  
  34. Also, when creating the macro, it only allows for 30 characters.  And it also
  35. only lets you enter in a ^P or ^C and of course printable text.  But it only
  36. allows a number after the ^P or ^C.  For those with the MERLIN9 MCI mod
  37. installed, this will keep your system from hanging, and also from users that
  38. would like to display userinfo in the name.  A safety precaution.  If your
  39. system uses some other color mod, and you can not figure out how to mod this
  40. mod to accept them, drop me a note as to what your system has for colors, and
  41. I will see what I can do.
  42.  
  43. ------------------------------------------------------------------------------
  44.  
  45. STEP 1  Backup your source.
  46.  
  47. ------------------------------------------------------------------------------
  48.  
  49. STEP 2 Add MODSTRIN.MOD.  This mod does use the mod.str file.  You don't need
  50. it, but it is used here in this mod.  Included is the instructions if you don't
  51. have MODSTRIN.MOD installed.
  52.  
  53. ------------------------------------------------------------------------------
  54.  
  55. STEP 3 FILE CONIO.C
  56.  
  57. In the function
  58.  
  59. void val_cur_user(void)
  60.  
  61. Search for and add the following lines
  62.  
  63.       case 5:
  64.         movecsr(wx+32,wy+3);
  65.         editline(restrict,16,SET,&rc,rst);
  66.         thisuser.restrict=0;
  67.         for (i=0; i<=15; i++)
  68.           if (restrict[i]!=32)
  69.             thisuser.restrict |= (1 << i);
  70.         if (thisuser.restrict & restrict_user_macro)             /* add me */
  71.           thisuser.umacro[0]='\0';                               /* add me */
  72.         break;
  73.       case 6:
  74.  
  75.  
  76. In the function
  77.  
  78. void topscreen(void)
  79.  
  80. Search for and add the following lines
  81.  
  82.       sprintf(ol,"Users: %4u       Total Calls: %5lu      Calls Today: %4u    P
  83. osted      :%3u ",
  84.          status.users,status.callernum1,status.callstoday,status.msgposttoday);
  85.       outs(ol);
  86.  
  87.       movecsr(0,2);
  88.       ts=1;                                                /* add me */
  89.       sprintf(ol,"%-36s      %-4u min   /  %2u%%    E-mail sent :%3u ",
  90.           nam(&thisuser,usernum),status.activetoday,
  91.           (int) (10*status.activetoday/144),status.emailtoday);
  92.       outs(ol);
  93.  
  94.       ts=0;                                                /* add me */ 
  95.       movecsr(0,3);                                      
  96.       sprintf(ol,"SL=%3u   DL=%3u               FW=%3u      Uploaded:%2u files 
  97.    Feedback    :%3u ",
  98.           thisuser.sl,thisuser.dsl,fwaiting,status.uptoday,status.fbacktoday);
  99.       outs(ol);
  100.       break;
  101.  
  102.  
  103. Just a few lines further down you will find this.  Add the lines indicated.
  104.  
  105.         if (strcmp(thisuser.laston,date()))
  106.     strcpy(lo,thisuser.laston);
  107.       else
  108.     sprintf(lo,"Today:%2d",thisuser.ontoday);
  109.  
  110.       movecsr(0,0);
  111.       ts=1;                                                /* add me */
  112.       sprintf(ol,"%-36s W=%2u UL=%4u/%6lu SL=%3u LO=%5u PO=%4u",
  113.       nam(&thisuser,usernum),thisuser.waiting,thisuser.uploaded,
  114.       thisuser.uk,thisuser.sl,thisuser.logons,thisuser.msgpost);
  115.       outs(ol);
  116.  
  117.       ts=0;                                                /* add me */ 
  118.       movecsr(0,1);                                        
  119.       if (thisuser.wwiv_regnum)
  120.     sprintf(calls,"%lu",thisuser.wwiv_regnum);
  121.       else
  122.     strcpy(calls,thisuser.callsign);
  123.       sprintf(ol,"%-20s %12s  %-6s DL=%4u/%6lu DL=%3u TO=%5.0lu ES=%4u",
  124.       thisuser.realname,thisuser.phone,calls,
  125.       thisuser.downloaded,thisuser.dk,thisuser.dsl,
  126.       ((long) ((thisuser.timeon+timer()-timeon)/60.0)),
  127.       thisuser.emailsent+thisuser.emailnet);
  128.  
  129.  
  130. ------------------------------------------------------------------------------
  131.  
  132. STEP 4 FILE DEFAULTS.C
  133.  
  134. In the function
  135.  
  136. void print_cur_stat(void)
  137.  
  138.   if (okansi()) {
  139.     pl(get_string(397)); /* "8. Change colors" */
  140.     outstr(get_string(398)); npr("%s\r\n", /* "9. Full screen editor: " */
  141.       ((thisuser.defed) && (thisuser.defed<=numed))?
  142.     editors[thisuser.defed-1].description:get_string(5)); /* "None." */
  143.     outstr(get_string(399)); npr("%s\r\n", /* "A. Extended colors   : " */
  144.       (thisuser.sysstatus & sysstatus_funky_colors)?str_yes:str_no);
  145.   }
  146.   outstr(get_string(400)); npr("%d\r\n",thisuser.optional_val); /* "B. Optional
  147.  lines    : " */
  148.   outstr(modstring(THEPROGRAMMER01));    /* See note 1 below */ /* add me */
  149.   if (thisuser.umacro[0])                                       /* add me */
  150.     list_macro(thisuser.umacro);                                /* add me */
  151.   else                                                          /* add me */
  152.     if (thisuser.restrict & restrict_user_macro)                /* add me */
  153.       pl( modstring(THEPROGRAMMER01+1)); /* See note 2 below */ /* add me */
  154.     else                                                        /* add me */
  155.       pl(get_string(402)); /* "<NONE>" */                       /* add me */
  156.   outstr(get_string(401)); /* "W. WWIV reg num      : " */
  157.   if (thisuser.wwiv_regnum)
  158.     npr("%ld\r\n",thisuser.wwiv_regnum);
  159.   else
  160.     pl(get_string(402)); /* "<NONE>" */
  161.  
  162. -------------------------------- ** Note 1 ** --------------------------------
  163. If you do not have the MODSTRIN.MOD installed.  Then replace that line with:
  164.       outstr("C. Username macro    : ");
  165.  
  166. -------------------------------- ** Note 2 ** --------------------------------
  167. If you do not have the MODSTRIN.MOD installed.  Then replace that line with:
  168.       pl("Not allowed");
  169.  
  170. In the function
  171.  
  172. void defaults(void)
  173.  
  174. Change the 2 lines to add the 'C' command (or whatever is free on your system)
  175.  
  176.     if (hangup)
  177.       return;
  178.     nl();
  179.     helpl=4;
  180.     if (okansi()) {
  181.       prt(2,get_string(477)); /* "Defaults: (1-9,A-B,W,?,Q) : " */
  182.       ch=onek("Q?123456789ABCW");                          /* change me */
  183.     } else {
  184.       prt(2,get_string(478)); /* "Defaults: (1-7,B,W,?,Q) : " */
  185.       ch=onek("Q?1234567BCW");                             /* change me */ 
  186.     }
  187.     switch(ch) {
  188.       case 'Q':
  189.     done=1;
  190.     break;
  191.  
  192. Further in the switch add the following lines.  You may need to change the
  193. case to a letter that is available.
  194.  
  195.       case 'B':
  196.     optional_lines();
  197.     break;
  198.       case 'C':                                            /* add me */
  199.     input_user_macro();                                /* add me */
  200.     break;                                             /* add me */
  201.       case 'W':
  202.     enter_regnum();
  203.     break;
  204.  
  205. At the end of the file add the following function.
  206.  
  207. void input_user_macro(void)
  208. {
  209.   unsigned char s[ 31],tempmac[ 31],s1[ 81];
  210.   int i, done1;
  211.   unsigned char ch1;
  212.  
  213.   if (thisuser.restrict & restrict_user_macro)
  214.     return;
  215.   strcpy(s,thisuser.umacro);
  216.   thisuser.umacro[0]=0;
  217.   done1=0;
  218.   i=0;
  219.   nl();
  220.   pl(get_string(449)); /* "Enter your macro now, hit ctrl-Z when done." */
  221.   nl();
  222.   okskey=0;
  223.   do {
  224.     ch1=getkey();
  225.     if (ch1==26)
  226.       done1=1;
  227.     else
  228.       if (ch1==8) {
  229.     if (i>0) {
  230.       i--;
  231.       backspace();
  232.       if (tempmac[i]<32)
  233.         backspace();
  234.     }
  235.       } else {
  236.     if (ch1>=' ') {
  237.       if ((tempmac[i-1]<' ') && (i)) {
  238.         if ((ch1>='0') && (ch1<='9')) {
  239.           tempmac[i++]=ch1;
  240.           outchr(ch1);
  241.         }
  242.       } else {
  243.         tempmac[i++]=ch1;
  244.         outchr(ch1);
  245.       }
  246.     } else {
  247.       if ((ch1==3) || (ch1==16)) {
  248.         if (((tempmac[i-1]<' ') && (i)) || (!i)){
  249.           tempmac[i++]=ch1;
  250.           outchr('^');
  251.           outchr(ch1+64);
  252.         }
  253.       }
  254.     }
  255.       }
  256.     if (i>=28)
  257.       done1=1;
  258.   } while ((!done1) && (!hangup));
  259.   okskey=1;
  260.   tempmac[i]=0;
  261.   nl();
  262.   pl(get_string(450)); /* "You entered:" */
  263.   nl();
  264.   nl();
  265.   list_macro(tempmac);
  266.   nl();
  267.   prt(5,get_string(438)); /* "Is this OK? " */
  268.   if (yn()) {
  269.     sprintf(s1,get_stringx(1,THEPROGRAMMER01_LOG),tempmac); 
  270.                               /* See note 3 below */
  271.     for (i=0; s1[i]; i++)
  272.       if (s1[i]=='\x10')
  273.     s1[i]='\x03';
  274.     sysoplog(s1);
  275.     strcpy(thisuser.umacro,tempmac);
  276.     nl();
  277.     pl(get_string(451)); /* "Macro saved." */
  278.   } else {
  279.     nl();
  280.     strcpy(&(thisuser.umacro[0]),s);
  281.     pl(get_string(452)); /* "Nothing saved." */
  282.   }
  283. }
  284.  
  285. -------------------------------- ** Note 3 ** --------------------------------
  286. This line is for the sysoplog, and I have put that string in the sysoplog.str
  287. file. I padded it out to 200 lines, and added the following line to it:
  288.  
  289. Username macro changed to '%s'
  290.  
  291. Now if you don't want to change the SYSOPLOG.STR file then just change it to:
  292.     sprintf(s1,"Username macro changed to '%s'",tempmac);
  293.  
  294. ------------------------------------------------------------------------------
  295.  
  296. STEP 5 FILE UEDIT.C
  297.  
  298. In the function
  299.  
  300. void uedit(int usern, int other)
  301.  
  302.  
  303. In the switch search for the case and add the lines indicated.
  304.  
  305.     case 'Z':
  306.       nl();
  307.       npr("        %s\r\n",restrict_string);
  308.       do {
  309.         prt(2,get_string(279)); /* "Toggle? " */
  310.         s[0]=13;
  311.         s[1]='?';
  312.         strcpy(&(s[2]),restrict_string);
  313.         ch1=onek(s);
  314.         if (ch1==32)
  315.           ch1=13;
  316.         if (ch1=='?')
  317.           printmenu(10);
  318.         if ((ch1!=13) && (ch1!='?')) {
  319.           i=-1;
  320.           for (i1=0; i1<16; i1++)
  321.         if (ch1==s[i1+2])
  322.           i=i1;
  323.           if (i>-1) {
  324.         u.restrict ^= (1 << i);
  325.         if (u.restrict & restrict_user_macro)      /* add me */
  326.           u.umacro[0]='\0';                        /* add me */
  327.         write_user(un,&u);
  328.           }
  329.         }
  330.       } while ((!hangup) && (ch1=='?'));
  331.       break;
  332.     case 'A':
  333.  
  334. ------------------------------------------------------------------------------
  335.  
  336. STEP 6 FILE UTILITY.C
  337.  
  338. Add the following function
  339.  
  340. char *name( userrec *u1)
  341. {
  342.   static char o[81];
  343.   int i,f,p;
  344.   userrec u;
  345.  
  346.   u=*u1;
  347.   f=1;
  348.   for (i=0; i<81; i++)
  349.     o[ i]='\0';
  350.   if ((u.umacro[0]) && (!ts)){
  351.     strcpy( o, u.umacro);
  352.     p=strlen(o);
  353.     o[p++]='\x03';
  354.     o[p++]='0';
  355.     o[p]='\0';
  356.     for (i=0; o[i]; i++)
  357.       if (o[i]=='\x10')
  358.     o[i]='\x03';
  359.   } else {
  360.     for (p=0; p<strlen(u.name); p++) {
  361.       if (f) {
  362.     if ((u.name[p]>='A') && (u.name[p]<='Z'))
  363.       f=0;
  364.     o[p]=u.name[p];
  365.       } else {
  366.     if ((u.name[p]>='A') && (u.name[p]<='Z'))
  367.       o[p]=u.name[p]-'A'+'a';
  368.     else {
  369.       if ((u.name[p]>=' ') && (u.name[p]<='/'))
  370.         f=1;
  371.       o[p]=u.name[p];
  372.     }
  373.       }
  374.     }
  375.   }
  376.   return( o);
  377. }
  378.  
  379. Replace the *nam function with the one provided here.
  380.  
  381. char *nam(userrec *u1, unsigned int un)
  382. {
  383.   char *o;
  384.   int p;
  385.   userrec u;
  386.  
  387.   u=*u1;
  388.   o=name(&u);
  389.   p=strlen(o);
  390.   o[p++]=32;
  391.   o[p++]='#';
  392.   itoa(un,&o[p],10);
  393.   return(o);
  394. }
  395.  
  396.  
  397. ------------------------------------------------------------------------------
  398. STEP 7 FILE VARDEC.H
  399. In userrec struct change this line:
  400.       
  401.       res_gp[100];    /* reserved for whatever */
  402.  
  403. To read as follows and add the one line:
  404.       
  405.       umacro[31],     /* Macro to be used for the username */ /* add me */
  406.       res_gp[69];     /* reserved for whatever */             /* change me */
  407.  
  408. In the userrec.restrict defines add the one indicated.  You might have to
  409. change the numbers if you have added your own.
  410.  
  411. /* userrec.restrict */
  412. #define restrict_logon 0x0001
  413. #define restrict_chat 0x0002
  414. #define restrict_validate 0x0004
  415. #define restrict_automessage 0x0008
  416. #define restrict_anony 0x0010
  417. #define restrict_post 0x0020
  418. #define restrict_email 0x0040
  419. #define restrict_vote 0x0080
  420. #define restrict_auto_msg_delete 0x0100
  421. #define restrict_net 0x0200
  422. #define restrict_upload 0x0400
  423. #define restrict_user_macro 0x0800                         /* add me */
  424.  
  425. The restrict_string macro will also be changed to add the macro restriction.
  426. Change this line:
  427.  
  428. #define restrict_string "LCMA*PEVKNU     "
  429.  
  430. To:
  431.  
  432. #define restrict_string "LCMA*PEVKNUO    "
  433.  
  434. Note:  You may have to adjust the string for your needs.  This is only based
  435. on stock WWIV source code.
  436.  
  437. ------------------------------------------------------------------------------
  438.  
  439. STEP 8 FILE VARS.H
  440.  
  441. You will need to add this variable anywhere in the defined area.  I put it
  442. right before the version info.
  443.  
  444. __EXTRN__ int ts;       /* for the top of screen name */
  445.  
  446.  
  447. ------------------------------------------------------------------------------
  448.  
  449. STEP 9
  450.  
  451. If you don't use a MOD.STR file then skip this step.
  452.  
  453. You will need to add these 2 lines in the MOD.STR file.  
  454.  
  455. "C. Username macro    : "
  456. "Not allowed"
  457.  
  458. Next you will need to define a macro that points to what line number is the
  459. start for the two strings. I put the macro in a file called MODSTR.H.  This
  460. is what mine looks like.
  461.  
  462. #define THEPROGRAMMER01 1
  463.  
  464. It is at the start of the MOD.STR file, so it is number 1.  Alternatively, you 
  465. could also put them right into BBS.STR file.
  466.  
  467. ------------------------------------------------------------------------------
  468.  
  469. STEP 10
  470.  
  471. If you decided to put that one string in the SYSOPLOG.STR file, then you will
  472. need to add another define that reads:
  473.  
  474. #define THEPROGRAMMER01_LOG 200
  475.  
  476. Where the 200 is the string number that you used in the sysoplog file.
  477.  
  478. ------------------------------------------------------------------------------
  479.  
  480. STEP 11
  481.  
  482. You will need to type "MAKE FCNS" from DOS so that the FCNS.H file can be
  483. updated.  Or you can edit FCNS.H to add the functions yourself.  The first
  484. one is preferrebly the easier one to do.
  485.  
  486. ------------------------------------------------------------------------------
  487.  
  488. STEP 12
  489.  
  490. Edit BBS.STR to change the 2 lines that have the options in the defaults area.
  491. You will need to add the 'C' to both lines.  They are line numbers 477 & 478.
  492.  
  493. 6### IMPORTANT NOTE ###0
  494.  
  495. DO NOT EDIT BBS.STR, NOR ANY OTHER STRING FILE, WITH A TEXT EDITOR.  USE ONLY 
  496. A PROGRAM THAT IS CAPABLE OF EDITING STRING FILES, SUCH AS THE MINIESM THAT IS
  497. INCLUDED WITH THE BBS.  YOU COULD (AND PROBABLY WOULD) END UP DAMAGING YOU BBS
  498. OTHERWISE.
  499.  
  500. ------------------------------------------------------------------------------
  501.  
  502. STEP 13
  503.  
  504. Recompile!
  505.  
  506. ------------------------6### ANOTHER IMPORTANT NOTE ###0------------------------
  507.  
  508. DO NOT CHANGE THE SIZE OF THE MACRO. IF YOU DO, YOUR EMAIL FILE WILL BECOME
  509. CORRUPTED.  POSSIBLY OTHER THINGS WILL BECOME CORRUPTED TOO.
  510.  
  511. Now that you done. Enjoy it!  If you find this mod useful.  Just drop a note
  512. saying that you are using it.  I am curious to see how many systems would
  513. find it useful, and use it.  If you have any suggestions for improvements or
  514. questions, again, drop a note with the suggestion.  I can be reached at 
  515. 1 @5903 on WWIVnet.
  516.  
  517. 2THE 1Programmer0
  518.